package quick_search

import "gorm.io/gorm"

var (
	_qsTagName = "find"
)

func Search(obj interface{}) func(*gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		cond := &Condition{}
		_, err := reflectObject(obj, cond)
		if err != nil {
			db.AddError(err)
			return db
		}

		return cond.Execute(db)
	}
}
